<!DOCTYPE html>
<html>
    <head>
        <meta charset="utf-8">
        <title>预览</title>
        <#include "/pubHeadStyle.html">
        <script src="${ctx}/extends/jquery.min.js" type="text/javascript"></script>
    </head>
    <body>
<div class="ccpui-tablesize dynamicAfferent" style="padding:10px;position: relative;">
    <table id="dynamicAfferent" lay-filter="dynamicAfferent"></table>
</div>
<div style="position: absolute;bottom: 15px;left: 37%;">
    <a class="layui-btn layui-btn-sm" id="queryShowData">
        <span>确定</span>
    </a>
    <a class="layui-btn layui-btn-sm layui-btn-danger" id="cancel">
        <span>取消</span>
    </a>
</div>
<script>
    layui.config({
        base: serverPath.formPath + staticPath.formPath //静态资源所在路径
    }).extend({
        index: 'index' //主入口模块
    }).use(['index', 'commons','table', 'layer', 'jquery', 'form', 'tree', 'common', 'totalFilter', 'setter', 'code'], function () {
        var table = layui.table, layer = layui.layer, setter = layui.setter, commons = layui.commons,
            common = layui.common;
        common.tableSort("formDialog");

        //动态传入的处理
        var conditionfield = JSON.parse('${bpmFormDialog.conditionfield}');
            table.render({
                elem: '#dynamicAfferent'
                , title: '自定义对话框表'
                , defaultToolbar: []
                , height: 'full-75'
                , data: conditionfield
                , cols: [[
                    , {field: 'field', title: '参数名', align: 'center',width:135}
                    , {field: 'paramValue', title: '参数值', align: 'center',width:225,templet: function (d) {
                                return "<input type='text' id='"+d.field +"' name='paramValue' class='layui-input'>";
                        }}
                    ]]
            });
        //取消
        $("#cancel").click(function(){
            var index = parent.layer.getFrameIndex(window.name);
            parent.layer.close(index);
        });

        //确定获取参数值传到预览页面
        $("#queryShowData").click(function(){
            var paramStr="?alias="+'${bpmFormDialog.alias}&dynamicPage=false&isOpenJsonData=true';
            if(isOpenShowDialog){
                paramStr+="&isOpenShowDialog=true";
            }
            for(var i=0;i<conditionfield.length;i++){
                if(conditionfield[i].defaultType ==="4"){
                   var paramValue= $("#"+conditionfield[i].field).val();
                   if(paramValue){
                       paramStr+="&"+conditionfield[i].field+"="+paramValue;
                   }
                }
            }
            var width = decibelRemoval('${bpmFormDialog.width}')+"px";
            var height = decibelRemoval('${bpmFormDialog.height}')+"px";
            var name = '${bpmFormDialog.name}';
            var isOpenShowDialog = '${isOpenShowDialog}';

            parent.layer.open({
                type: 2,
                title: name,
                shade: 0.3,
                area: [width,height],
                content: serverPath.formPath + setter.formLinkPath + "formDialog/view/show"+paramStr
            });
        });

        //去除千分位
        function decibelRemoval(num){
            if (num  == "") {
                return "";
            }
            num=num.replace(/,/gi,'');
            return num;
        }
    });
</script>
<style>
    .dynamicAfferent .layui-table-view .layui-table{
        width: 100%;
    }
    .layui-table-cell{
        height: auto !important;
    }
    .layui-table-cell .laytable-cell-1-0-1{
        width: 225px;
    }
</style>
    </body>
</html>